package com.app.toknow.View;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.app.toknow.R;


/**
 * Created by kangw on 2015/10/5.
 */
public class ToastDialog {
    private static ToastDialog toastDialog;

    private Toast toast;

    private ToastDialog(){
    }

    public static ToastDialog createToastConfig(){
        if (toastDialog==null) {
            toastDialog = new ToastDialog();
        }
        return toastDialog;
    }

    public void ToastShow(Context context,String tvString){
        View layout = LayoutInflater.from(context).inflate(R.layout.toast_dialog,null);
        TextView text = (TextView) layout.findViewById(R.id.toast_text);
        text.setText(tvString);
        text.setTextColor(Color.BLACK);
        toast = new Toast(context);
        toast.setGravity(Gravity.CENTER_VERTICAL, 0, 120);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(layout);
        toast.show();
    }
}
